package com.dingwei.lesyndrome.mvp.presenter;

import com.dingwei.lesyndrome.base.FailsBean;
import com.dingwei.lesyndrome.base.MyBaseBean;
import com.dingwei.lesyndrome.bean.GamCircleTypeBean;
import com.dingwei.lesyndrome.custom.myCallback;
import com.dingwei.lesyndrome.mvp.view.Contract;
import com.lihao.baselibrary.base.BaseActivity;
import com.lihao.baselibrary.base.URLS;
import com.lihao.baselibrary.base.basePresenter;

import org.xutils.http.RequestParams;
import org.xutils.x;

/**
 * Created by lihao on 2017/9/12.
 */

public class NewsPresenter extends basePresenter {

    private Contract.NewsView newsView;

    public NewsPresenter(Contract.NewsView view) {
        super(view);
        this.newsView = view;
    }


    public void initData() {
        RequestParams rp = new RequestParams(URLS.HOST + URLS.NEWS_CATE_LIST);
        x.http().post(rp, new myCallback(BaseActivity.context, GamCircleTypeBean.class, rp) {
            @Override
            public void back(MyBaseBean baseBean, String result) {
                GamCircleTypeBean bean = (GamCircleTypeBean) baseBean;
                newsView.setData(bean);
            }

            @Override
            public void fail(FailsBean baseBean, String result) {
                newsView.onFail();
            }
        });
    }
}
